package com.kgc.controller;

import com.kgc.pojo.Order;
import com.kgc.service.GetOrderInfoService;
import com.kgc.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GetOrderInfo_wzlController {

    @Autowired
    private GetOrderInfoService getOrderInfoService;

    /*获取订单详情信息*/
    @GetMapping("getOrderdetailinfo_wzl")
    public Object getOrderdetailinfo_wzl() {
        List<Order> list = getOrderInfoService.getorderinfo();
        return new Result(list, "获取订单信息成功");
    }
    /*删除订单信息*/
    @PostMapping("deleOrderInfo_wzl")
    public Object deleOrderInfo_wzl(int id){
        int count = getOrderInfoService.deleOrderinfo(id);
        int count2 =getOrderInfoService.deleDeliveryInfo(id);
        return new Result(count, "订单删除成功");
    }
    /*更新订单信息*/
    @PostMapping("updateOrderInfo_wzl")
    public Object  updateOrderInfo_wzl(@RequestParam("ordernum") String ordernum, @RequestParam("ticketname") String ticketname,@RequestParam("money") String money,
                                       @RequestParam("id") Integer id, @RequestParam("deliveryways") String deliveryways , @RequestParam("receiveraddress")String receiveraddress,
                                       @RequestParam("receiver")String receiver, @RequestParam("phone")String phone, @RequestParam("carriage")String carriage){
        int count = getOrderInfoService.updateOrderInfo_wzl(ordernum, ticketname, money, id);
        int count2 =getOrderInfoService.updateDeliveryinfo(deliveryways,receiveraddress,receiver,phone,carriage,id);

        return new Result(true,"信息更新成功");
    }
}
